package com.boco.action;

import java.util.ArrayList;
import java.util.List;

import com.boco.dao.GetEMR_MJZZLXJPYBGData;
import com.boco.dao.SentData;
import com.boco.entity.EMR_MJZZLXJPYBG;

public class InsertEMR_MJZZLXJPYBGDataAction {
	public  String insertData(){
		String url = "http://fasong.cdxp.csb/json/dzbl4";
		String resule = null;
		List<EMR_MJZZLXJPYBG> list = new ArrayList<EMR_MJZZLXJPYBG>();
		list = GetEMR_MJZZLXJPYBGData.getData();
		String userName = "dzbl4";
		String password = "322dfbf9048445cabb06cbf24e64cdcf";
		EMR_MJZZLXJPYBG temp = null;
		for(int i=0;i<list.size();i++){
			String param = null;
			temp = list.get(i);
			System.out.println(temp.getXM());
			//按照身份证删除已经存在的值。
			param = "{\"SQL\":\"delete  EMR_MJZZLXJPYBG where YLJGZZJGDM='"+
					temp.getYLJGZZJGDM()
					+"' and MJZH = '"+temp.getMJZH()+"'"
					+ "\", \"ANNOTION\":\"cdxplogs\"}";
			resule = SentData.sendPost(url, param, userName, password);
			System.out.println("删除结果："+resule);
			param = "{\"SQL\":\"INSERT INTO EMR_MJZZLXJPYBG ("
					+ "HZZSYH,"
					+ "YLJGZZJGDM,"
					+ "YLJGMC,"
					+ "MJZH,"
					+ "MJZZLYPMYLSH,"
					+ "XM,"
					+ "XBDM,"
					+ "XB,"
					+ "CSRQ,"
					+ "SZNL,"
					+ "JZLSH,"
					+ "JYSQDH,"
					+ "JYBGDH,"
					+ "XJDH,"
					+ "XJMC,"
					+ "YMDM,"
					+ "YMMC,"
					+ "KYJGDM,"
					+ "KYJG,"
					+ "CKZ,"
					+ "JYFF,"
					+ "JYJG,"
					+ "DYXH,"
					+ "JYJGDM,"
					+ "JYJGMC,"
					+ "ORGCODE,"
					+ "AREACODE,"
					+ "UPLOADTIME,"
					+ "SOURCEID"
					+ ") VALUES("
					+ "'" + checkStr(temp.getHZZSYH()) + "'," 
					+ "'" + checkStr(temp.getYLJGZZJGDM()) + "'," 
					+ "'" + checkStr(temp.getYLJGMC()) + "'," 
					+ "'" + checkStr(temp.getMJZH()) + "'," 
					+ "'" + checkStr(temp.getMJZZLYPMYLSH()) + "'," 
					+ "'" + checkStr(temp.getXM()) + "'," 
					+ "'" + checkStr(temp.getXBDM())+ "'," 
					+ "'" + checkStr(temp.getXB()) + "'," 
					+ "'" + checkStr(temp.getCSRQ()) + "'," 
					+ "'" + checkStr(temp.getSZNL()) + "'," 
					+ "'" + checkStr(temp.getJZLSH()) + "'," 
					+ "'" + checkStr(temp.getJYSQDH()) + "'," 
					+ "'" + checkStr(temp.getJYBGDH()) + "'," 
					+ "'" + checkStr(temp.getXJDH()) + "'," 
					+ "'" + checkStr(temp.getXJMC()) + "'," 
					+ "'" + checkStr(temp.getYMDM()) + "'," 
					+ "'" + checkStr(temp.getYMMC()) + "'," 
					+ "'" + checkStr(temp.getKYJGDM()) + "'," 
					+ "'" + checkStr(temp.getKYJG()) + "'," 
					+ "'" + checkStr(temp.getCKZ()) + "'," 
					+ "'" + checkStr(temp.getJYFF()) + "'," 
					+ "'" + checkStr(temp.getJYJG()) + "'," 
					+ "'" + checkStr(temp.getDYXH()) + "'," 
					+ "'" + checkStr(temp.getJYJGDM()) + "'," 
					+ "'" + checkStr(temp.getJYJGMC()) + "'," 
					+ "'" + checkStr(temp.getORGCODE()) + "'," 
					+ "'" + checkStr(temp.getAREACODE()) + "'," 
					+ "sysdate," 
					+ "'dzbl4'" 
					+ ")\", \"ANNOTION\":\"cdxplogs\"}";
					resule = SentData.sendPost(url, param, userName, password);
					System.out.println(resule);
					
		}
		return resule;
		
	
		
	}
	
	public static String checkStr(Object obj){
		if (obj== null){
			obj = "";
		}
		return (String) obj;
	}
	
	
}
